#include "common.h"

int main()
{
  umask(0);
  if(mkfifo(IPC_PATH, 0666) < 0){
    //make fail
    std::cerr << "make fail" << std::endl;
  }

  int fd = open(IPC_PATH, O_RDONLY);
  while(true){
    int type = 0;
    ssize_t s = read(fd, &type, sizeof(int));

    if(s == 0){
      //end
      std::cout << "read out" << std::endl;
      break;
    }//if
    else if(s < 0){
      //read error
      std::cerr << "read fail" << std::endl;
      break;
    }//else if
    else{
      //success
      std::cout << "read success, operation: " << type << std::endl;
    }
  }//while

  return 0;
}
